package cn.gson.crm.model.pojos;

import javax.persistence.*;
import java.util.List;
import java.util.Objects;

@Entity
public class Role {
    private long jId;
    private String jName;
    private Long jZil;
    private  Dept dept;
    private List<Function> functionList;
    private List<Role> roleList;
    private Role role;
    @ManyToOne
    @JoinColumn(name = "j_id",updatable = false,insertable = false)
    public Role getRole() {
        return role;
    }

    public void setRole(Role role) {
        this.role = role;
    }

    @OneToMany(mappedBy = "role")
    public List<Role> getRoleList() {
        return roleList;
    }

    public void setRoleList(List<Role> roleList) {
        this.roleList = roleList;
    }

    @ManyToMany
    @JoinTable(name = "role_function",
            joinColumns = {
                    @JoinColumn(name="j_id")
            },
            inverseJoinColumns = {
                    @JoinColumn(name = "g_id")
            })
    public List<Function> getFunctionList() {
        return functionList;
    }

    public void setFunctionList(List<Function> functionList) {
        this.functionList = functionList;
    }

    @ManyToOne
    @JoinColumn(name = "DEPT_ID", referencedColumnName = "DEPT_ID")
    public Dept getDept() {
        return dept;
    }

    public void setDept(Dept dept) {
        this.dept = dept;
    }
    @Basic
    @Column(name = "J_ZIL")
    public Long getjZil() {
        return jZil;
    }

    public void setjZil(Long jZil) {
        this.jZil = jZil;
    }
    @Id
    @Column(name = "j_id")
    @GeneratedValue(generator = "seq",strategy = GenerationType.SEQUENCE)
    //定义一个序列生成器
    @SequenceGenerator(name = "seq",sequenceName = "crm",
            initialValue = 1,allocationSize = 1)
    public long getjId() {
        return jId;
    }

    public void setjId(long jId) {
        this.jId = jId;
    }

    @Basic
    @Column(name = "j_name")
    public String getjName() {
        return jName;
    }

    public void setjName(String jName) {
        this.jName = jName;
    }




}
